{% layout="admin_layout.html" %}
{-title-}
{(admin.articles/menu.html)}
{-title-}
{-content-}
<div class="row-fluid">
    <div class="span12">
        <table class="table table-hover">
            <thead>
                <tr>
                    <th class="span4">文章标题</th>
                    <th class="span6">内容</th>
                    <th class="span2">操作</th>
                </tr>
            </thead>
            <tbody>
                {%for k,a in pairs(articles) do %}
                <form name="sdfsdf" action="{{helper:url('admin/articles/destroy')}}" method="post">
                    <tr>
                        <td class="text-justify" >
                            <a href="{{helper:url('article/index',{['id']=a['id']})}}">{{a['title']}}</a> 
                        </td>
                        <td  style="word-break: break-all;word-wrap: break-word;">{{helper:substr(helper:strip_tag(a['content']),400,400)}}</td>
                        <td>              
                            <div class="btn-group" role="group" aria-label="...">
                                <a class="btn btn-default" href="{{helper:url('admin/articles/edit',{id=a['id']})}}">更新</a>
                                <input type="hidden" name="id" value="{{a['id']}}">
                                <input type="submit" class="btn btn-default" value="删除"/>
                                {% if helper:intval(a['close_comment'])>0 then %}
                                <button type="button" aid="{{a['id']}}" class="btn btn-default">关闭评论</button>
                                {%else%}
                                <button type="button" aid="{{a['id']}}" class="btn btn-default">开启评论</button>
                                {%end%}
                            </div>
                        </td>
                    </tr>
                </form>
                {%end%}
            </tbody>
        </table>
        {% if page then%}
        {(page.html, {pageobj=page})}
        {%end%}
    </div>
</div>
<script language="JavaScript">
    <!--
    jQuery(function($){
        $('[aid]').click(function(){
            var $this=$(this);
            var $aid=$this.attr('aid');
            $.ajax({
                type: 'post',
                url:"{*helper:url('admin/articles/comment_close')*}",
                data: {aid:$aid},
                dataType:'json',
                success: function(R){
                    if(R.code){
                        alert(R.msg);
                    }else{
                        if($this.html()=='关闭评论'){
                            $this.html('开启评论');
                        }else{
                            $this.html('关闭评论');
                        }
                    }
                } 
            });
        })
    });
    //-->
</script>
{-content-}